﻿@using GoodMan.Infrastructure.Entities.Entity;
@using GoodMan.Infrastructure.Entities.Enum;
@using GoodMan.Portal.Biz;
@{
    Layout = "~/Views/Shared/_Main.cshtml";
}
<br />
<div class="row-fluid">
    <div class="span3">
        <div class="border-gray bg-gray">
            <ul class="nav nav-list">
                <li class="nav-header">用户管理</li>
                <!--active-->
                <li class=""><a href="/usercenter/index">管理首页</a></li>
                <li class="active"><a href="/usercenter/order">我的订单</a></li>
                <li class=""><a href="/usercenter/info">个人资料</a></li>
                <li class=""><a href="/usercenter/mypwd">修改密码</a></li>
            </ul>
        </div>
    </div>
    <div class="span9">
        <ul class="breadcrumb">
            <li><a href="user-center.html">管理首页</a> <span class="divider">/</span></li>
            <li class="active">我的订单</li>
        </ul>
        <table class="table table-x">
            <thead>
                <tr>
                    <th>
                        商品名称
                    </th>
                    <th style="width:15%">
                        单价
                    </th>
                    <th style="width:30%">
                        交易
                    </th>
                    <th style="width:10%">
                        状态
                    </th>
                    <th style="width:28%">
                    </th>
                </tr>
            </thead>
            <tbody>
                @{
                    ItemListBox<Order> orders = ViewBag.Orders;
                    if (orders != null && orders.Data != null && orders.Data.Any())
                    {
                        foreach (var item in orders.Data)
                        {
                    <tr>
                        <td>
                            <div style="width:180px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;display:block;"><a href="/usercenter/orderdetail/@item.Id" target="_blank">@Html.Raw(item.ProductDescript)</a></div>
                        </td>
                        <td>
                            @if(item.AreaCode == AreaCode.Integration)
                            {
                                string rank = System.Configuration.ConfigurationManager.AppSettings["costrank"];
                                int r = 1;
                                if(!String.IsNullOrEmpty(rank) && Int32.TryParse(rank.ToString(),out r))
                                {
                                    <span>积分：@(item.TotalPrice * r)</span>
                                }
                                else
                                {
                                    <span> - </span>
                                }
                            }
                            else
                            {
                                <span> @item.TotalPrice 元 </span>
                            }
                        </td>
                        <td>
                            <small>订单号：@item.OrderCode<br />
                                成交：@item.OrderDate.ToString("yyyy-MM-dd HH:ss")</small>
                        </td>
                        <td>
                             @if(item.Status == OrderStatus.Completed)
                                {
                                    <span class="label label-success">@item.Status.Mapping()</span>
                                }
                                else if(item.Status == OrderStatus.WaitForDeliver || item.Status == OrderStatus.Paid)
                                {
                                    <span class="label label-warning">@item.Status.Mapping()</span>
                                }
                                else if(item.Status == OrderStatus.Reserved)
                                {
                                    <span class="label label-info">@item.Status.Mapping()</span>
                                }
                                else
                                {
                                    <span class="label">@item.Status.Mapping()</span>
                                }
                        </td>
                        <td>
                            @if(item.Status == OrderStatus.Reserved)
                            {
                                <a class="btn btn-success btn-mini" href="/shop/UserCenterPay/@item.Id" >立即付款</a>
                            }
                            <a href="/usercenter/orderdetail/@item.Id" class="btn btn-primary btn-mini">订单详情</a>
                            @if (item.Status == OrderStatus.Completed)
                            {
                                if(OrderBiz.IsViewAppraisie(item.Id))
                                {
                                <a href="/usercenter/ProductAppraisie/@item.Id" class="btn btn-primary btn-mini">评价</a>
                                }
                                else
                                {
                                    <span>已评</span>
                                }
                            }
                        </td>
                    </tr>
                        }
                    }
                }
            </tbody>
            <tfoot>
                <tr>
                    <th colspan="5">
                    </th>
                </tr>
            </tfoot>
        </table>
        @Html.Raw(orders.PageItemSegment)
        <br />
    </div>
</div>
